/*cineplex.h*/
#ifndef CINEPLEX_H
#define CINEPLEX_H

#define MAX_CUSTOMERS 26
#define MAX_TIX_CLERKS 5
#define MAX_FOOD_CLERKS 5
#define MAX_TIX_TAKERS 3
#define MAX_ROWS 5
#define MAX_COLS 5
#define MAX_GROUP_SIZE 7

/*define agent type numbers*/
#define T_CUSTOMER 0
#define T_MANAGER 1
#define T_TICKETCLERK 2
#define T_FOODCLERK 3
#define T_TICKETTAKER 4
#define T_LOBBY 5
#define T_MOVIETECH 6

struct Message{
	int name;
	int sender;
};

#include "definitions.h"
#include "syscall.h"
#include "customer.h"
#include "manager.h"
#include "lobby.h"
#include "movietech.h"
#include "ticketclerk.h"
#include "foodclerk.h"
#include "tickettaker.h"
#include "line.h"

struct Ticket{
	int num;
};

struct Soda{
	int num;
};

struct Popcorn{
	int num;
};

struct Seat{
	int row;
	int col;
};

int NUM_CUSTOMERS;
int NUM_TIX_CLERKS;
int NUM_FOOD_CLERKS;
int NUM_TIX_TAKERS;
int NUM_ROWS;
int NUM_COLS;

int i, j, k, t1, t2, t3, t4, t5;
static int RandInit = 0;

/*condition for intialization of theater*/
int initCond;
int agentsStarted;

int custLock;
int initLock;
int loopLock;
int tempLock;

int outputLen;
char outBuff[32];

int nextC;
int nextTC;
int nextFC;
int nextTT;

struct Customer customers[MAX_CUSTOMERS];
struct TicketClerk tixClerks[MAX_TIX_CLERKS];
struct Line tixLines[MAX_TIX_CLERKS];
struct FoodClerk foodClerks[MAX_FOOD_CLERKS];
struct Line foodLines[MAX_FOOD_CLERKS];
struct Line entryLines[MAX_TIX_TAKERS];
struct TicketTaker tixTakers[MAX_TIX_TAKERS];
struct Manager manager;
struct Lobby lobby;
struct MovieTech tech;

int groups[MAX_CUSTOMERS/MAX_GROUP_SIZE + 1][MAX_GROUP_SIZE];
struct Seat seatAssign[MAX_CUSTOMERS];
int groupSizes[MAX_CUSTOMERS/MAX_GROUP_SIZE + 1];
int groupNums[MAX_CUSTOMERS];

/*theater data*/
int seating[MAX_ROWS * MAX_COLS];
int seatingLock;
int seatsFilled;
int totalSeats ;
int movieStarted; /*bool*/

/*bathroom*/
int brLock;
int brLoop;

/*locks*/
int tixLinesLock;
int foodLinesLock;
int entryLinesLock;
int poolLock;

struct Ticket ticketPool[MAX_CUSTOMERS];
struct Popcorn popcornPool[MAX_CUSTOMERS];
struct Soda sodaPool[MAX_CUSTOMERS];

int isLeader[MAX_CUSTOMERS];

/*assorted variables*/
int tixPassedOut;
int popcornSold;
int sodaSold;
int customersRunning;
int letPeopleIn;
int runSchedulers;
int numGroups;

void startCineplex();
static void startCustomer();
static void startSub();
static void startTC();
static void startFC();
static void startTT();
static void startManager();
static void startTech();
static void startLobby();
int getRandPercent();

void SendMessage(int type, int index, int name, int sender); /*if pointers work, ??????*/

#endif